{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 7.24 Laminar Flow"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Objective: Rate an orifice plate in laminar flow"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Problem statement: calculate the Reynolds number to determine the type of fluid\n",
    "    \n",
    "Given: S.A.E. 10W oil flows through a 3\" schedule 40 pipe. It has a measured delta P of 0.4 psi. The orifice plate has a 2.15\" diameter bore, and is a standard sharp-edged orifice. Find the flow rate through the orifice in gallons/minute."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from fluids.units import *\n",
    "from math import pi\n",
    "\n",
    "NPS, Di, Do, t = nearest_pipe(NPS=3, schedule='40')\n",
    "A = 0.25*pi*Di*Di\n",
    "D2 = 2.15*u.inch\n",
    "mu = 40*u.cP # given\n",
    "rho = 53.6*u.lb/u.ft**3\n",
    "\n",
    "# Assume an absolute pressure of 5 bar.\n",
    "dP = 0.4*u.psi\n",
    "P1 = 5*u.bar\n",
    "P2 = P1-dP\n",
    "k = 1.3 # assumed\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Flow rate is: 88.00974933637421 gallon / minute\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "1947.5090707193106 dimensionless"
      ],
      "text/latex": [
       "$1947.5090707193106\\ dimensionless$"
      ],
      "text/plain": [
       "1947.5090707193106 <Unit('dimensionless')>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# First calculate the orifice with the standard formula\n",
    "m = differential_pressure_meter_solver(D=Di, rho=rho, mu=mu, k=k, D2=D2, P1=P1, P2=P2, \n",
    "                                   m=None, meter_type='ISO 5167 orifice', \n",
    "                                   taps='corner')\n",
    "Q = (m/rho).to_base_units()\n",
    "print('Flow rate is: %s'% Q.to(u.gal/u.min))\n",
    "v = Q/A\n",
    "Re = rho*v*Di/mu\n",
    "Re.to_base_units()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Because the flow rate is laminar, outside the range of the ISO formula, we turn to another set of data - a set of CFD results developed for laminar flow by Hollingshead."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Flow rate is: 77.16025233085325 gallon / minute\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "1707.4277843809423 dimensionless"
      ],
      "text/latex": [
       "$1707.4277843809423\\ dimensionless$"
      ],
      "text/plain": [
       "1707.4277843809423 <Unit('dimensionless')>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# First calculate the orifice with the standard formula\n",
    "m = differential_pressure_meter_solver(D=Di, rho=rho, mu=mu, k=k, D2=D2, P1=P1, P2=P2, \n",
    "                                   m=None, meter_type='Hollingshead orifice')\n",
    "Q = (m/rho).to_base_units()\n",
    "print('Flow rate is: %s'% Q.to(u.gal/u.min))\n",
    "v = Q/A\n",
    "Re = rho*v*Di/mu\n",
    "Re.to_base_units()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The answer given in Crane is that a calibration for the meter must be provided. They assume a `C` of 0.75. The value of `C` according to Hollingshead is below."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "0.7156763185721802 dimensionless"
      ],
      "text/latex": [
       "$0.7156763185721802\\ dimensionless$"
      ],
      "text/plain": [
       "0.7156763185721802 <Unit('dimensionless')>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "differential_pressure_meter_C_epsilon(D=Di, D2=D2, m=m, P1=P1, P2=P2, rho=rho, mu=mu, k=k, \n",
    "                                          meter_type='Hollingshead orifice')[0]"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
